package com.hex.ds.hdrs.app.converter;

import com.hex.bigdata.hbda.utils.SecurityUtils;
import com.hex.ds.hdrs.app.dto.AppExecStrategyDto;
import com.hex.ds.hdrs.app.po.AppExecStrategyPo;
import com.hex.ds.hdrs.common.utils.BaseUtil;
import com.hex.ds.hdrs.common.utils.HdrsDateUtil;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

/**
 * @Package com.hex.ds.hdrs.app.converter
 * @ClassName IAppExecStrategyConverter
 * @Description 应用策略关联表转换器
 * @Author yu liuyang
 * @Date 2023/4/18 14:12
 * @Version v1.0
 **/
@Mapper(componentModel = "spring", imports = {BaseUtil.class, SecurityUtils.class, HdrsDateUtil.class})
public interface IAppExecStrategyConverter {

    /**
     * @Method setDefaultForAdd <br>
     * @Param [appExecStrategy] <br>
     * @Return com.hex.ds.hdrs.app.po.AppExecStrategy <br>
     * @Description 为AppExecStrategy设默认值，用于应用与策略添加 <br>
     * @Author yu liuyang <br>
     * @Date 2023/4/18 14:13 <br>
     * @Version V1.0 <br>
     */
    @Mapping(target = "pkId", expression = "java(BaseUtil.getPkId())")
    @Mapping(target = "crtUser", expression = "java(SecurityUtils.getUsername())")
    @Mapping(target = "upUser", expression = "java(SecurityUtils.getUsername())")
    @Mapping(target = "crtTs", expression = "java(HdrsDateUtil.getCurrentTime())")
    @Mapping(target = "upTs", expression = "java(HdrsDateUtil.getCurrentTime())")
    @Mapping(target = "appCode", source = "appCode")
    AppExecStrategyPo setDefaultForAdd(AppExecStrategyDto appExecStrategyDto, String appCode);

    List<AppExecStrategyDto> toAppExecStrategyDtoList(List<AppExecStrategyPo> appExecStrategyPos);

}
